<?php
namespace app\api\controller;

use app\api\middleware\Auth;
use think\cache\driver\Redis;
use think\Request;
use think\captcha\facade\Captcha;
use think\facade\Cache;
use think\facade\View;

class User
{
    protected $middleware=[Auth::class. ':api' 	=> ['only' 	=> ['test'] ]];
    public function login(Request $request)
    {
        return success($request->params['msg']);
    }
    public function test(Request $request)
    {

        //$redis = new Redis();
        Cache::set('mytp6test','testmen');
       // $redis->set('mytp6test','testmen');
        $test=Cache::get('mytp6test');
        View::assign('test',$test);
        View::assign('defaultderive',Cache::getDefaultDriver());
        //return success($request->param());
        return view('test');
    }
    public function checkcape(Request $request)
    {
        $value=$request->param('capastr');
        
        $key = session('captcha.key');
        # code...
        if( !captcha_check($value))
        {
            // 验证失败
            return fail(['验证码是：'.$key],'请输入正确的验证码');
        }
        else
        {
            return success('成功');
        }
         
    }
}
